package edu.gatech.cs4235.group3.action;


/**
 * This OnePadEncryptAction encrypts files specified with the One-Time pad files.
 * 
 * 
 * @author Jeffrey Starker
 *
 */
public class OnePadEncryptAction extends OnePadCryptAction {
	
	/**
	 * Creates a OnePadEncryptAction with the even parameters.
	 *
	 * @param filesToEncrypt A comma separated list of files to encrypt.
	 * @param onePadFiles A comma separated list of one time pad files.
	 */
	public OnePadEncryptAction(final String filesToEncrypt, final String onePadFiles) {
		super(filesToEncrypt, onePadFiles);
	}

	/**
	 * Returns the type of this Action "encrypt".
	 * 
	 * @return "encrypt"
	 */
	@Override
	public String getCryptType() {
		return "encrypt";
	}


	/**
	 * This method decrypts the files using the one-time pads.
	 * 
	 */
	@Override
	protected char crypt(final char cryptValue, final char padValue) {
		
		int cryptValueInt = cryptValue - 32;
		int padValueInt = padValue - 32;
		
		// Perform encrypt.
		return (char) (((cryptValueInt + padValueInt) % 95) + 32);
	}

}
